package com.example.concurrent.chapter05;

import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * @author Create By Liuqz
 * @date 2018/11/21 16:50
 */
public interface Lock {

    /**
     * lock()方法永远阻塞,除非获取了锁,这一点和synchronized非常类似,但是该方法可以被中断,中断时抛出InterruptedException异常
     * @throws InterruptedException
     */
    void lock() throws InterruptedException;

    /**
     * lock(long mills) 方法除了可以被中断外,还增加了对应的超时功能
     * @param mills
     * @throws InterruptedException
     * @throws TimeoutException
     */
    void lock(long mills) throws InterruptedException,TimeoutException;

    /**
     * unlock() 用于对锁的释放
     */
    void unlock();

    /**
     * getBlockedThreads() 用于获取档当前哪些线程被阻塞
     * @return
     */
    List<Thread> getBlockedThreads();


}
